package com.ntschy.common.valid.idCard;


import cn.hutool.core.util.StrUtil;

import java.util.regex.Pattern;

public class IdCardValidationUtil {
    private static final Pattern PATTERN = Pattern.compile("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$");
    /**
     * 验证身份证号码
     */
    public static boolean isIdCard(String iphone){
        if (StrUtil.isEmpty(iphone)) {
            return false;
        } else {
            return PATTERN.matcher(iphone).matches();
        }
    }
}